package com.stars.module.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.stars.base.entity.CommonDTO;
import com.stars.base.entity.UserSelectDTO;
import com.stars.module.user.entity.StarOrgUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrgUserMapper extends MPJBaseMapper<StarOrgUser> {
    @Select("SELECT U.*,OO.ORGNAME FROM STAR_USER U " +
            "LEFT JOIN STAR_ORGUSER O ON U.ID = O.USER_ID " +
            "INNER JOIN STAR_ORGANIZES OO ON OO.ID = O.ORG_ID " +
            "WHERE ( U.NAME LIKE CONCAT('%',#{search},'%') )  AND U.ROWSTATUS > -1 ORDER BY OO.SHOWORDER,U.SHOWORDER")
    List<StarOrgUser> loadUserDetail(UserSelectDTO dto);

    @Update("UPDATE STAR_ORGUSER SET IS_MAIN = 0 WHERE USER_ID = #{uid}")
    void updatePartTimeDept(String uid);
}
